package com.guo.bootvue.controller;

import com.guo.bootvue.api.CommonResult;
import com.guo.bootvue.entity.User;
import com.guo.bootvue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther Heart Guo
 * @Date 2021/12/20-11:33
 */
@RestController
@RequestMapping("/boot")
@ResponseBody
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public CommonResult login(@RequestBody User user){
        String username = user.getUsername();
        String password = user.getPassword();
        user = userService.login(username,password);
        if(user !=null){
            return CommonResult.success("成功");
        }else {
            return CommonResult.validateFailed("失败");
        }
    }
}
